html,
body {
  width: 100%;
  height: 100%;
  display: flex;
}
:root {
  --borderColor: #03a9f3;
}
div {
  position: relative;
  width: 140px;
  height: 64px;
  margin: auto;
  border: 1px solid #03a9f3;
  cursor: pointer;
}
div::before,
div::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  transition: 0.3s ease-in-out;
}
div::before {
  top: -5px;
  left: -5px;
  border-top: 1px solid var(--borderColor);
  border-left: 1px solid var(--borderColor);
}
div::after {
  right: -5px;
  bottom: -5px;
  border-bottom: 1px solid var(--borderColor);
  border-right: 1px solid var(--borderColor);
}
div:hover::before,
div:hover::after {
  width: calc(100% + 9px);
  height: calc(100% + 9px);
}
/*
借用了元素的两个伪元素。
两个伪元素分别只设置上、左边框，下、右边框，通过 hover 时改变两个伪元素的高宽即可
*/
